package com.huaxin.device.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.huaxin.device.dto.ResponseResult;
import com.huaxin.device.dto.request.DeviceAlarmPageListReqDTO;
import com.huaxin.device.models.DeviceAlarm;
import com.huaxin.device.service.DeviceAlarmService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Tag(name = "设备报警信息")
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/device/deviceAlarm")
public class DeviceAlarmController {
    private final DeviceAlarmService service;

    @GetMapping("/getByDeviceAlarmId")
    @Operation(summary = "获取设备报警信息", description = "获取设备报警信息")
    public DeviceAlarm getByDeviceAlarmId(@Parameter(description = "设备报警信息ID", name = "id", required = true) @RequestParam(name = "id", required = true) String id) {
        return service.getByDeviceAlarmId(id);
    }

    @PostMapping("/pageQuery")
    @Operation(summary = "分页查询设备报警信息", description = "分页查询设备报警信息")
    public ResponseResult<IPage<DeviceAlarm>> pageQuery(@RequestBody @Valid DeviceAlarmPageListReqDTO in) {
        return service.pageQuery(in);
    }

    @GetMapping("/resolve")
    @Operation(summary = "解决设备报警", description = "解决设备报警")
    public ResponseResult<Boolean> resolve(@Parameter(description = "设备报警信息ID", name = "id", required = true) @RequestParam(name = "id", required = true) String id) {
        return service.resolve(id);
    }

    @GetMapping("/unResolve")
    @Operation(summary = "未解决设备报警", description = "未解决设备报警")
    public ResponseResult<Boolean> unResolve(@Parameter(description = "设备报警信息ID", name = "id", required = true) @RequestParam(name = "id", required = true) String id) {
        return service.unResolve(id);
    }
}
